[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'ID=' 中。

来源:百度知道 编辑:UC知道 时间:2024/05/25 09:03:08
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'ID=' 中。
/test/addok.asp, 第 20 行

文件:addok.asp:

1 <!--#include file="connections/conn.asp"-->
2 <%
3 function encodestr(str)
4 dim i
5 str=trim(str)
6 str=replace(str,"<","<")
7 str=replace(str,">",">")
8 str=replace(str,"'","""")
9 str=replace(str,vbCrLf&vbCrlf,"</p><p>")
10 str=replace(str,vbCrLf,"<br>")
11 encodestr=replace(str," "," ")
12 end function
13
14 title=encodestr(request.form("title"))
15 news_content=replace(trim(request.form("news_content")),"'","''")
16 guestcontent=encodestr(request.form("guestcontent

肯定是session("maxid")空值了
18行写得不够严谨,改一下:
if isnull(session("maxid")) or session("maxid")="" then session("maxid")=0
或者这样:
if session("maxid")&""="" then session("maxid")=0

始终要注意一点
是"where id='"&id&"'"还是"where id="&id
当不确定sql是否正解的时候

Response.Write(sql)
Response.End()
来查看sql是否是自己想要的内容

改成这个:sql="update content set title='"&title&"',guestcontent='"&guestcontent&"',news_content='"&news_content&"',classname='"&classname&"' where ID='" & session("maxid")&"'"

纪录集sql先声明,也就是说你们没有先打开一个数据库的记录

你的id肯定是字符型的,改为sql="update content set title='"&title&"',guestcontent='"&guestcontent&"',news_content='"&news_content&"',classname='"